package dmqm.mall.utils;

import com.alibaba.fastjson.JSON;

public class JsonBuilder {
    public static final int ERROR_CODE = 200001;
    public static final int SUCCESS_CODE = 400001;

    public static String Info(int code, String msg) {
        return new Result(code, msg).toJsonString();
    }

    public static String Info(int code, String msg, Object obj) {
        return new Result(code, msg, obj).toJsonString();
    }


    static class Result {
        private int code;
        private String msg;
        private Object obj;

        public Result(int code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public Result(int code, String msg, Object obj) {
            this.code = code;
            this.msg = msg;
            this.obj = obj;
        }

        public int getCode() {
            return code;
        }

        public void setCode(int code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        public Object getObj() {
            return obj;
        }

        public void setObj(Object obj) {
            this.obj = obj;
        }

        public String toJsonString() {
            return JSON.toJSONString(this);
        }

    }
}
